home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / crc.doc < prev    next >
Text File  |  1995-03-31  |  2KB  |  41 lines

  1. (Comp.sys.handhelds) 
  2. Item: 928 by cloos at acsu.buffalo.edu 
  3. Author: [James H. Cloos] 
  4.   Subj: CRC routine for 48 
  5.   Date: Thu Oct 18 1990 12:06  
  6.  
  7. Enclosed is a crc routine that takes as input a hex dump of the form: 
  8. "84E2040D814C474" 
  9. and returns a binary integer (in that case #807Ch) corresponding to what 
  10. BYTES would return from the original object. 
  11.  
  12. For instance, the above dump corresponds to 
  13. 84E20  :  ID 
  14. 40     :  length is 0x4 BYTES 
  15. D8     :  ascii code of \-> 
  16. 14     :    "    "   "  A 
  17. C$     :    "    "   "  L 
  18. 74     :    "    "   "  G 
  19.  
  20. Add the crc in reverse field format and you get the string: 
  21. "84E2040D814C474C708" 
  22. which when fed into ASC\-> returns '\->ALG' 
  23.  
  24. What does this all mean?  Well, with this you can put together a hex string, 
  25. get the crc, attatch the crc, put a \n after every 64th character, and 
  26. use ASC\-> to compile it.  Why is this better than using the STR\->OBJ 
  27. program previously posted (& avail in all of the archives) you ask? 
  28. Simple: ASC\-> is more forgiving.  Even if the crc is correct for the given 
  29. sequence of nybbles, ASC\->, in my testing, kills the compiled obj and gives 
  30. you an "Invalid string error." when displaying the compiles obj would crash. 
  31. (Ie., I compiled some gibberish, as well as some hex dumps that had typos 
  32. with both methods.  ASC\-> never crashed (unless you gave it a 4 char string 
  33. such as "0000"!) but STR\->OBJ dutifully compiled the junk and left it on 
  34. the stack.  Here we bombed.  (Actually, they may not have even gotten THAT 
  35. far, but the end result is the same.)  Besides, the algorithm is useful 
  36. for more than just this, and can be converted back to C, though if you do 
  37. this, remember to do it a nybble at a time, not a byte at a time. 
  38.  
  39. I should point out that the algorithm comes from kermit (see _KERMIT - 
  40. A File Transfer Protocol_ by Frank da Cruz, Digital Press, 1987. p. 257). 
  41.